package com.yuxiu.edu.service.impl;

import com.yuxiu.edu.model.Employee;
import com.yuxiu.edu.service.IEmployeeService;
import com.yuxiu.edu.service.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService{


    @Override
    public List<Employee> findByAll() {
        return employeeMapper.findAll();
    }

    public List<Employee> findByText(String text) {
        return employeeMapper.selectText(text);
    }
    @Override
    public Employee findById(Integer id) {
        return employeeMapper.selectByPrimaryKey(id);
    }
    @Override
    public void deleteById(Integer id)  {
        employeeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Employee findByUUID(String uuid) {
        return null;
    }

    @Override
    public void deleteByUUID(String uuid) {

    }

    @Override
    public void saveOrUpdate(Employee employee) {

        if(employee.getId() ==  null){
            employeeMapper.insert(employee);
            //int i = 10 / 0;
        }else{
            employeeMapper.updateByPrimaryKeySelective(employee);
        }
    }
    @Override
    public void insert(Employee employee) {

    }
}
